/**
 * 
 */
package com.zhang.junit;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Before;
import org.junit.Test;

import com.zhang.Dao.UserDao;
import com.zhang.Dao.impl.UserDaoimpl;
import com.zhang.pojo.User;

/**
 * @张博皓
 *2017年11月17日
 */
public class mybatisdaoTest {
	private SqlSessionFactory sqlsessionfaction;
	@Before
	public void befor() throws IOException{
		String resource ="sqlMapConfig.xml";
		//加载核心配置文件
		InputStream in= Resources.getResourceAsStream(resource);
		//创建sqlsession工厂
		sqlsessionfaction = new SqlSessionFactoryBuilder().build(in);
		
	}
	
	@Test
	public void testdao	(){
	UserDao userdao=new UserDaoimpl(sqlsessionfaction);
	User u=userdao.SelectuserByid(10);
	System.out.println(u);

	}
}